----------------------------------------------------------------------------------------------------------------------------------
--[[



]]--
----------------------------------------------------------------------------------------------------------------------------------
local loramia_com_power_device = Class(function(self, inst)
    self.inst = inst
    -------------------------------------------------------------------------
    -- 指示器
        self.indicator = nil
        self.display_indicator = false
        self.display_indicator_radius = 1
        self.__display_indicator = net_bool(inst.GUID,"display_indicator","display_indicator_param_update")
        self.__display_indicator_radius = net_float(inst.GUID,"display_indicator_radius","display_indicator_param_update")
        if not TheNet:IsDedicated() then
            inst:ListenForEvent("display_indicator_param_update",function()
                self.display_indicator = self.__display_indicator:value()
                self.display_indicator_radius = self.__display_indicator_radius:value()
            end)
            inst:ListenForEvent("loramia_com_power_device_indicator_active",function(_,placer_inst)
                ------------------------------------------------------------------------------------
                --- 控制表
                    --[[
                        做自适应兼容，还有call_back
                        placer_inst 可以是 inst ，
                        也可以是 { 
                            placer = inst ,
                            call_back = {
                            }
                        }
                    ]]--
                    local cmd_table = nil
                    if placer_inst.components == nil then
                        cmd_table = placer_inst
                        placer_inst = cmd_table.placer
                        cmd_table.call_back = cmd_table.call_back or {}
                    end
                    if cmd_table then

                    end
                ------------------------------------------------------------------------------------
                --- 激活指示器
                    if placer_inst then
                        self:ActiveIndicator()
                        placer_inst:ListenForEvent("onremove",function()
                            self:DeactiveIndicator()
                        end)
                    end
                ------------------------------------------------------------------------------------
            end,TheWorld)
        end
    -------------------------------------------------------------------------
    -- 指示器颜色
        self.indicator_color = {0,1,1}
    -------------------------------------------------------------------------
end)
------------------------------------------------------------------------------------------------------------------------------
--- 指示器
    function loramia_com_power_device:SetIndicatorColor(r,g,b)
        self.indicator_color = {r,g,b}
        self:SetIndicator(true)
    end
    function loramia_com_power_device:GetIndicatorColor(unpack_flag)
        if unpack_flag then
            return unpack(self.indicator_color)
        end
        return self.indicator_color
    end
    function loramia_com_power_device:SetIndicator(flag)
        if TheWorld.ismastersim then
            self.__display_indicator:set(flag)
        end
        self.display_indicator = flag
    end
    function loramia_com_power_device:SetIndicatorRadius(radius)
        if TheWorld.ismastersim then
            self.__display_indicator_radius:set(radius)
        end
        self.display_indicator_radius = radius
    end
    function loramia_com_power_device:ActiveIndicator()
        if self.indicator and self.indicator:IsValid() then
            self.indicator:Remove()
        end
        if not self.display_indicator then
            return
        end
        local indicator = SpawnPrefab("loramia_sfx_dotted_circle_client")
        indicator:PushEvent("Set",{
            pt = Vector3(self.inst.Transform:GetWorldPosition()),
            radius = self.display_indicator_radius,
        })
        self.indicator = indicator
        indicator:ListenForEvent("onremove",function()
            indicator:Remove()
        end,self.inst)
        -- indicator.AnimState:SetAddColour(0, 1, 1, 0)
        -- indicator.AnimState:SetMultColour(0, 1, 1, 1)
        local r,g,b = self:GetIndicatorColor(true)
        indicator.AnimState:SetAddColour(r,g,b, 0)
        indicator.AnimState:SetMultColour(r,g,b, 1)
        indicator.AnimState:SetBloomEffectHandle("shaders/anim.ksh")
    end
    function loramia_com_power_device:DeactiveIndicator()
        if self.indicator and self.indicator:IsValid() then
            self.indicator:Remove()
            self.indicator = nil
        end
    end
------------------------------------------------------------------------------------------------------------------------------
return loramia_com_power_device







